package io.github.hayeka.excel.model;

import java.util.List;

/**
 * program:
 * description:
 * author:
 * create: 2021/8/27
 **/
public class Sheet<T> {

    private Class clazz;

    private List<T> list;

    public Sheet(Class clazz, List<T> list) {
        check(clazz, list);
        this.clazz = clazz;
        this.list = list;
    }

    private void check(Class clazz, List<T> list) {
        if (clazz == null) {
            throw new RuntimeException("clazz不能为空");
        }
        if (list == null || list.size() == 0) {
            throw new RuntimeException("list不允许微null或者size必须大于0");
        }
        T t = list.get(0);
        if (t.getClass() != clazz) {
            throw new RuntimeException("clazz与list中的内容必须是同一个类");
        }
    }

    public Class getClazz() {
        return clazz;
    }

    public void setClazz(Class clazz) {
        this.clazz = clazz;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
